function wallCollision() {
    let canvas = document.getElementById("_canvas");
    let ctx = canvas.getContext("2d");
    let engine = new Engine(ctx);
    let layer = new Layer(ctx);
    engine.addLayer(layer);
    
    layer.create = function () {
        let walls = createWall(canvas, ctx, layer);

        let rect1 = new RectObject();
        rect1.x = 300;
        rect1.y = 400;
        rect1.width = 150;
        rect1.height = 150;
        rect1.moving = true;
        rect1.direction = MathUtil.deg2rad(225);
        rect1.speed = 50;

        rect1.addComponent(new GameComponent.MouseDrag());
        rect1.update = function (delta) {
            this.rotation -= MathUtil.deg2rad(10 * delta);
            if (this.rotation < 0) {
                this.rotation += Math.PI * 2;
            }
        }
        let flags = {};
        rect1.addCollisionEvent(walls[0], function (event) {

            console.log('up');
            rect1.strokeStyle = 'red';
            rect1.direction = (Math.PI * 2 - rect1.direction) % Math.PI;
            console.log('wall_0');
        }, function (event) {
            rect1.strokeStyle = 'black';
        });

        rect1.addCollisionEvent(walls[1], function (event) {
            console.log('right');
            rect1.strokeStyle = 'red';
            console.log('wall_1');
            rect1.direction = Math.PI * 2 - (rect1.direction - Math.PI)
        }, function (event) {
            rect1.strokeStyle = 'black';
        });

        rect1.addCollisionEvent(walls[2], function (event) {
            console.log('down');
            rect1.strokeStyle = 'red';
            console.log('wall_2');
            rect1.direction = Math.PI * 2 - rect1.direction;
        }, function (event) {
            rect1.strokeStyle = 'black';
        });

        rect1.addCollisionEvent(walls[3], function (event) {
            console.log('left');
            rect1.strokeStyle = 'red';
            console.log('wall_3');
            rect1.direction = Math.PI - rect1.direction;
        }, function (event) {
            rect1.strokeStyle = 'black';
        });

        layer.addObject(rect1);
    }
    engine.run();
    return engine;
}
